#include<stdio.h>
#include<unistd.h>

//用来观察进程地址空间的code
int gval = 100;

int main()
{
    pid_t id = fork();
    if(id == 0)
    {
        printf("id = %d, &id = %p\n",id,&id);
        while(1)
        {
            printf("子：gval：%d, &gval：%p,pid: %d,ppid: %d\n",gval,&gval,getpid(),getppid());
            sleep(1);
            gval++;
        }
    }
    else 
    {
        printf("id = %d, &id = %p\n",id,&id);
        while(1)
        {
            printf("父：gval：%d, &gval：%p,pid: %d,ppid: %d\n",gval,&gval,getpid(),getppid());
            sleep(1);
        }   
    }
    return 0;
}
